<template>
  <!-- 红包弹层 -->
  <transition
    enter-active-class="animated bounceIn"
    leave-active-class="animated bounceOutRight">
    <div v-show="value"  class="red-packet-pop red-packet-big">
      <div class="bg"></div>
      <div flex="dir:top cross:center" class="content">
        <slot name="title">
          <img v-if="money>0" class="title title-hh" src="../assets/images/sm-red-package-title.png"/>
          <img v-else class="title title-hh" src="../assets/images/opfu.png"/>
        </slot>

        <div class="body body-hh" v-if="money>0">
          <slot name="body">
            <img src="../assets/images/red-packet-big.png" alt="">
            <div v-if="money>0" class="money tc">{{money/100}}元</div>
          </slot>
        </div>
	     	<div class="body body-hh" v-else>
          <slot name="body">
            <img :src='cardShowImgSrc[card-1]'  alt="">
          </slot>
        </div>

        <slot name="footer" v-if="money>0">
          <div class="btns btns-hh" @click='targetHref(isAppAlert,"/red-packet")'>
            <img class="btn hh" src="../assets/images/see-btn.png"/>
            <img src="../assets/images/gesture.png" alt="" class="gesture">
          </div>
        </slot>
        <slot name="footer" v-else>
          <div class="btns btns-hh" @click='targetHref(isAppAlert,"/cards")'>
            <img class="btn hh" src="../assets/images/see-btn.png"/>
            <img src="../assets/images/gesture.png" alt="" class="gesture">
          </div>
        </slot>

        <!--<p class="logan tc">集齐八张福卡 瓜分百万现金</p>-->
         <div style="width: 80%;margin:auto;"><img src="../assets/images/jq8.png"/></div>
      </div>
    </div>
  </transition>
</template>

<script>
  // 卡
  import cardHui from '../assets/images/card-hui.png';
  import cardShang from '../assets/images/card-shang.png';
  import cardChe from '../assets/images/card-che.png';
  import cardFu from '../assets/images/card-fu.png';
  import cardGong from '../assets/images/card-gong.png';
  import cardHe from '../assets/images/card-he.png';
  import cardXin from '../assets/images/card-xin.png';
  import cardChun from '../assets/images/card-chun.png';
  import hscfApi from '../assets/js/hscfApi.js';
  import libs from '../assets/js/libs.js';

  export default {
    props: {
      type: {
        default: '1',
        require: false,
        type: String
      },
      money: {
        type: Number,
        default: 0
      },
      value: {
        default: false,
        require: true,
        type: Boolean
      },
      card:{
        default:1,
        require:false,
        type:Number
      },
      isAppAlert:{
        default:0,
        require:true,
        type:Number
      }
    },
    methods:{
      close(){
        this.val = null;
        this.$emit("input",false);
        hscfApi.closeWebView();
        location.reload();
      },
      targetHref(num,src){
        var url = `${location.protocol}//${location.host}`;
        if(process.env.NODE_ENV !== 'development'){
          url+=src;
        }else{
          url+="/#"+src;
        }
          if(num==1){//是app控制的弹框 调用app的tosee()方法
            hscfApi.goToSee(url);
          }else{
            this.$router.push({path:src});
          }
      }
    },
    data(){
      return{
        src:null,
        cardShowImgSrc: [cardHui, cardShang, cardChe, cardFu, cardGong, cardHe, cardXin, cardChun],

      }
    }
  }
</script>

<style lang="scss">
  @import "../assets/css/funcs.scss";

  .red-packet-pop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .9);
    .bg, .content {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 2;
    }
    @keyframes flash {
      from {
        opacity: 0;
      }
      to {
        opacity: 1;
      }
    }
    .bg {
      background: url("../assets/images/light.png") -30% center no-repeat;
      background-size: cover;
      z-index: 1;
      animation: flash 0.5s ease-in-out infinite alternate;
    }
    .content {
      justify-content: space-between;
    }
    img {
      max-width: 100%;
    }
    .title {
      margin-top: pxToRem(60px);
      height: 12.7%;
    }
    .body {
      height: 44%;
      margin: pxToRem(50px) 0 pxToRem(40px);
      position: relative;
      img {
        height: 100%;
      }
      .money {
        position: absolute;
        bottom: 28%;
        font-size: pxToRem(70px);
        width: 100%;
        font-weight: bold;
        color: white;
      }
    }
    .btns {
      display: inline-block;
      position: relative;
      .btn {
        width: pxToRem(250px);
        &:not(:first-child) {
          margin-left: pxToRem(20px);
        }
      }
    }
    .logan {
      font-size: pxToRem(40px);
      color: $yellow;
    }
    @keyframes tap {
      from {
        top: pxToRem(40px);
        right: pxToRem(-30px);
        opacity: 0;
      }
      to {
        opacity: 1;
        top: pxToRem(30px);
        right: pxToRem(-20px);
      }
    }
    .gesture {
      width: pxToRem(68px);
      height: auto !important;
      top: pxToRem(30px);
      right: pxToRem(-20px);
      position: absolute;
      animation: tap 1s infinite;

    }
  }
</style>
